package com.ruoyi.mall.home.service.impl;

import com.ruoyi.mall.home.domain.CmsSubjectInfo;
import com.ruoyi.mall.home.domain.PmsBrandInfo;
import com.ruoyi.mall.home.domain.PmsProductInfo;
import com.ruoyi.mall.home.domain.UmsUserInfo;
import com.ruoyi.mall.home.domain.dto.AdminHomeInfoDto;
import com.ruoyi.mall.home.mapper.AdminHomeMapper;
import com.ruoyi.mall.home.service.IAdminHomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdminHomeServiceImpl implements IAdminHomeService {

    @Autowired
    AdminHomeMapper adminHomeMapper;

    @Override
    public AdminHomeInfoDto selectAdminHomeInfo() {
        int onCount = adminHomeMapper.countPublishStatus0();
        int offCount = adminHomeMapper.countPublishStatus1();
        int recommendCount = adminHomeMapper.countRecommend();
        int productCount = adminHomeMapper.countProduct();
        PmsProductInfo pmsProductInfo = new PmsProductInfo();
        pmsProductInfo.setOnCount(onCount);
        pmsProductInfo.setOffCount(offCount);
        pmsProductInfo.setRecommendCount(recommendCount);
        pmsProductInfo.setProductCount(productCount);
        UmsUserInfo umsUserInfo = new UmsUserInfo();
        umsUserInfo.setTodayIncreased(0);
        umsUserInfo.setYesterdayIncreased(0);
        umsUserInfo.setMonthIncreased(0);
        umsUserInfo.setUserCount(0);
        PmsBrandInfo pmsBrandInfo = new PmsBrandInfo();
        int factoryCount = adminHomeMapper.countFactory();
        int brandCount = adminHomeMapper.countBrand();
        pmsBrandInfo.setFactoryCount(factoryCount);
        pmsBrandInfo.setBrandCount(brandCount);
        CmsSubjectInfo cmsSubjectInfo = new CmsSubjectInfo();
        int showCount = adminHomeMapper.countSubjectShow();
        int subjectCount = adminHomeMapper.countSubject();
        cmsSubjectInfo.setShowCount(showCount);
        cmsSubjectInfo.setSubjectCount(subjectCount);
        AdminHomeInfoDto adminHomeInfoDto = new AdminHomeInfoDto();
        adminHomeInfoDto.setPmsProductInfo(pmsProductInfo);
        adminHomeInfoDto.setUmsUserInfo(umsUserInfo);
        adminHomeInfoDto.setPmsBrandInfo(pmsBrandInfo);
        adminHomeInfoDto.setCmsSubjectInfo(cmsSubjectInfo);
        return adminHomeInfoDto;
    }
}